package com.ljkj.zjf.service;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ljkj.common.db.dao.ZjfBlessDAO;
import com.ljkj.common.db.dao.ZjfCarItemDAO;
import com.ljkj.common.db.dao.ZjfCliffordDAO;
import com.ljkj.common.db.dao.ZjfCliffordRecordDAO;
import com.ljkj.common.db.dao.ZjfGoodsActivityDAO;
import com.ljkj.common.db.dao.ZjfGoodsActivityRecordDAO;
import com.ljkj.common.db.dao.ZjfGoodsAdDAO;
import com.ljkj.common.db.dao.ZjfGoodsClassDAO;
import com.ljkj.common.db.dao.ZjfGoodsDAO;
import com.ljkj.common.db.dao.ZjfGoodsTypeDAO;
import com.ljkj.common.db.dao.ZjfLabelDAO;
import com.ljkj.common.db.dao.ZjfOrderDAO;
import com.ljkj.common.db.dao.ZjfOrderItemDAO;
import com.ljkj.common.db.dao.ZjfPaymentDAO;
import com.ljkj.common.db.dao.ZjfUserAddressDAO;
import com.ljkj.common.db.dao.ZjfUserDAO;
import com.ljkj.common.db.domain.ZjfBlessingLanguage;
import com.ljkj.common.db.domain.ZjfCarItem;
import com.ljkj.common.db.domain.ZjfClifford;
import com.ljkj.common.db.domain.ZjfCliffordRecord;
import com.ljkj.common.db.domain.ZjfGood;
import com.ljkj.common.db.domain.ZjfGoodsActivity;
import com.ljkj.common.db.domain.ZjfGoodsActivityRecord;
import com.ljkj.common.db.domain.ZjfGoodsAd;
import com.ljkj.common.db.domain.ZjfGoodsClass;
import com.ljkj.common.db.domain.ZjfGoodsType;
import com.ljkj.common.db.domain.ZjfLabel;
import com.ljkj.common.db.domain.ZjfOrder;
import com.ljkj.common.db.domain.ZjfOrdersItem;
import com.ljkj.common.db.domain.ZjfPayment;
import com.ljkj.common.db.domain.ZjfUser;
import com.ljkj.common.db.domain.ZjfUserAddress;
import com.ljkj.common.db.util.Contants;
import com.ljkj.common.db.util.DateTime;
import com.ljkj.common.db.util.RandomCode;
import com.ljkj.common.db.util.StringUtil;
import com.ljkj.zjf.common.ArithUtil;
import com.ljkj.zjf.common.DateUtil;
import com.ljkj.zjf.common.GlobalNames;
/**
 * 报警器服务接口实现类 
 * @author 李竺桐  20160719
 *
 */
public class WechatService{
	ZjfGoodsClassDAO zjfGoodsClassDAO;
	ZjfGoodsTypeDAO zjfGoodsTypeDAO;
	ZjfGoodsDAO zjfGoodsDAO;
	ZjfGoodsAdDAO zjfGoodsAdDAO;
	ZjfGoodsActivityDAO zjfGoodsActivityDAO;
	ZjfCliffordDAO zjfCliffordDAO;
	ZjfCliffordRecordDAO zjfCliffordRecordDAO ;
	ZjfGoodsActivityRecordDAO zjfGoodsActivityRecordDAO;
	ZjfUserAddressDAO zjfUserAddressDAO;
	ZjfUserDAO zjfUserDAO;
	ZjfLabelDAO zjfLabelDAO;
	ZjfBlessDAO zjfBlessDAO;
	ZjfCarItemDAO zjfCarItemDAO;
	ZjfOrderDAO zjfOrderDAO;
	ZjfOrderItemDAO zjfOrderItemDAO;
	ZjfPaymentDAO zjfPaymentDAO ;
	/**
	 * 查询商品分类
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryGoodsClass(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String class_type_id = strJsonObject.getString("class_type_id"); //类型编码

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (class_type_id == null ||class_type_id.equals("")) {
			resultMap.put("errmessage", "类型编码不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfGoodsClass.class};
		//是否显示 1显示 0 不显示
		String[] propertyNames=new String[]{ "classTypeId","classDisplay","disabledState"};
		Object[] values=new String[]{class_type_id,"1","0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = new String[]{"classSequence"};
		orderByValues =  new String[]{"ASC"};
		Integer currentPage=null;
		List<ZjfGoodsClass> zjfGoodsClass = zjfGoodsClassDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", zjfGoodsClass);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 查询商品类型
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryGoodsType(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);

		Class[] pojos = {ZjfGoodsType.class};
		String[] propertyNames=new String[]{ "disableState"};
		Object[] values=new String[]{"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = new String[]{"typeSequence"};
		orderByValues =  new String[]{"ASC"};
		Integer currentPage=null;
		List<ZjfGoodsType> zjfGoodsType = zjfGoodsTypeDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", zjfGoodsType);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 查询商品列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryCliffordGoodsList(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);
		String page = strJsonObject.getString("page"); //当前页数
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);

		Class[] pojos = {ZjfGood.class,ZjfGoodsClass.class};
		//goodsCliffordStatus 是否为聚福商品 1 为 是聚福
		String[] propertyNames=new String[]{ "zjfGoodsClass.classId","zjfGood.goodsCliffordStatus","zjfGood.disabledState","zjfGoodsClass.disabledState"};
		Object[] values=new String[]{"zjfGood.goodsClassId","1","0","0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		if (!StringUtil.isNullOrEmpty(page)) {
			currentPage=Integer.valueOf(page);
		}

		List<Object[]> dataList  = zjfGoodsDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfGoodsClass zjfGoodsClass=new ZjfGoodsClass();
			zjfGoodsClass=zjfGoodsClass.setNewObject((ZjfGoodsClass) objects[1]);
			object.put("zjfGood", (ZjfGood) objects[0]);
			object.put("zjfGoodsClass",zjfGoodsClass);
			ary.add(object);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据商品分类查询商品列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryCliffordGoodsListByClass(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String class_type_id = strJsonObject.getString("class_type_id"); //类型编码

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (class_type_id == null ||class_type_id.equals("")) {
			resultMap.put("errmessage", "类型编码不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfGood.class,ZjfGoodsClass.class};
		//goodsCliffordStatus 是否为聚福商品 1 为 是聚福
		String[] propertyNames=new String[]{ "zjfGood.goodsClassId", "zjfGoodsClass.classId","zjfGood.goodsCliffordStatus","zjfGood.disabledState","zjfGoodsClass.disabledState"};
		Object[] values=new String[]{class_type_id,"zjfGood.goodsClassId","1","0","0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<Object[]> dataList = zjfGoodsDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfGoodsClass zjfGoodsClass=new ZjfGoodsClass();
			zjfGoodsClass=zjfGoodsClass.setNewObject((ZjfGoodsClass) objects[1]);
			object.put("zjfGood", (ZjfGood) objects[0]);
			object.put("zjfGoodsClass",zjfGoodsClass);
			ary.add(object);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", dataList);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据ID查询商品
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryCliffordGoodById(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String goodsId = strJsonObject.getString("goodsId"); //商品ID

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (goodsId == null ||goodsId.equals("")) {
			resultMap.put("errmessage", "商品ID不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfGood.class,ZjfGoodsClass.class};
		//goodsCliffordStatus 是否为聚福商品 1 为 是聚福
		String[] propertyNames=new String[]{ "zjfGood.goodsId", "zjfGoodsClass.classId","zjfGood.goodsCliffordStatus","zjfGood.disabledState","zjfGoodsClass.disabledState"};
		Object[] values=new String[]{goodsId,"zjfGood.goodsClassId","1","0","0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<Object[]> dataList = zjfGoodsDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfGoodsClass zjfGoodsClass=new ZjfGoodsClass();
			zjfGoodsClass=zjfGoodsClass.setNewObject((ZjfGoodsClass) objects[1]);
			object.put("zjfGood", (ZjfGood) objects[0]);
			object.put("zjfGoodsClass",zjfGoodsClass);
			ary.add(object);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", dataList);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 查询商品列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryGoodsList(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);

		Class[] pojos = {ZjfGood.class,ZjfGoodsClass.class};
		//goodsCliffordStatus 是否为聚福商品 1 为 是聚福
		String[] propertyNames=new String[]{ "zjfGoodsClass.classId","zjfGood.disabledState","zjfGoodsClass.disabledState"};
		Object[] values=new String[]{"zjfGood.goodsClassId","0","0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<Object[]> dataList= zjfGoodsDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfGoodsClass zjfGoodsClass=new ZjfGoodsClass();
			zjfGoodsClass=zjfGoodsClass.setNewObject((ZjfGoodsClass) objects[1]);
			object.put("zjfGood", (ZjfGood) objects[0]);
			object.put("zjfGoodsClass",zjfGoodsClass);
			ary.add(object);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据商品分类查询商品列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryGoodsListByType(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String class_type_id = strJsonObject.getString("class_type_id"); //类型编码

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (class_type_id == null ||class_type_id.equals("")) {
			resultMap.put("errmessage", "类型编码不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfGood.class,ZjfGoodsType.class};
		//goodsCliffordStatus 是否为聚福商品 1 为 是聚福
		String[] propertyNames=new String[]{ "zjfGood.goodsClassId", "zjfGoodsType.typeId","zjfGood.disabledState","zjfGoodsType.disableState"};
		Object[] values=new String[]{class_type_id,"zjfGood.goodsClassId","0","0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<Object> dataList = zjfGoodsDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", dataList);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据ID查询商品
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryGoodById(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String goodsClassId = strJsonObject.getString("goodsClassId"); //类型编码

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (goodsClassId == null ||goodsClassId.equals("")) {
			resultMap.put("errmessage", "类型编码不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfGood.class,ZjfGoodsClass.class};
		//goodsCliffordStatus 是否为聚福商品 1 为 是聚福
		String[] propertyNames=new String[]{ "zjfGood.goodsClassId", "zjfGoodsClass.classId","zjfGood.disabledState","zjfGoodsClass.disabledState"};
		Object[] values=new String[]{goodsClassId,"zjfGood.goodsClassId","0","0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<Object[]> dataList  = zjfGoodsDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfGoodsClass zjfGoodsClass=new ZjfGoodsClass();
			zjfGoodsClass=zjfGoodsClass.setNewObject((ZjfGoodsClass) objects[1]);
			object.put("zjfGood", (ZjfGood) objects[0]);
			object.put("zjfGoodsClass",zjfGoodsClass);
			ary.add(object);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 获取推荐商品列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryRecommendGoodsList(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);

		Class[] pojos = {ZjfGood.class,ZjfGoodsClass.class};
		//goodsRecommend是否为推荐商品 1 为 是推荐
		String[] propertyNames=new String[]{ "zjfGoodsClass.classId","zjfGood.goodsRecommend","zjfGood.disabledState","zjfGoodsClass.disabledState"};
		Object[] values=new String[]{"zjfGood.goodsClassId","1","0","0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<Object[]> dataList = zjfGoodsDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfGoodsClass zjfGoodsClass=new ZjfGoodsClass();
			zjfGoodsClass=zjfGoodsClass.setNewObject((ZjfGoodsClass) objects[1]);
			object.put("zjfGood", (ZjfGood) objects[0]);
			object.put("zjfGoodsClass",zjfGoodsClass);
			ary.add(object);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 获取广告列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryADList(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);

		Class[] pojos = {ZjfGoodsAd.class};
		String[] propertyNames=new String[]{ "zjfGoodsAd.disabledState"};
		Object[] values=new String[]{"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		orderByPropertyNames = new String[]{"zjfGoodsAd.adSequence"};
		orderByValues =  new String[]{"ASC"};
		Integer currentPage=null;

		List<ZjfGoodsAd> dataList = zjfGoodsAdDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", dataList);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据ID获取广告列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryADByID(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String adId = strJsonObject.getString("adId"); //广告ID

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (adId == null ||adId.equals("")) {
			resultMap.put("errmessage", "广告ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfGoodsAd.class};
		String[] propertyNames=new String[]{"zjfGoodsAd.adId", "zjfGoodsAd.disabledState"};
		Object[] values=new String[]{adId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfGoodsAd> dataList = zjfGoodsAdDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", dataList);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 获取众筹、活动列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryActivityList(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String page = strJsonObject.getString("page"); //当前页数
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);

		Class[] pojos = {ZjfGoodsActivity.class};
		String[] propertyNames=new String[]{ "zjfGoodsActivity.disabledState"};
		Object[] values=new String[]{"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;
		if (!StringUtil.isNullOrEmpty(page)) {
			currentPage=Integer.valueOf(page);
		}
		List<ZjfGoodsActivity> dataList = zjfGoodsActivityDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(ZjfGoodsActivity vo:dataList){
			object=new JSONObject();
			JSONObject objectR=new JSONObject();
			int personcount=0;
			double total=0;
			pojos = new Class[]{ZjfGoodsActivityRecord.class};
			propertyNames=new String[]{"zjfGoodsActivityRecord.activityId", "zjfGoodsActivityRecord.disabledState"};
			values=new String[]{vo.getActivityId(),"0"};
			List<ZjfGoodsActivityRecord> recordList = zjfGoodsActivityRecordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
			for(ZjfGoodsActivityRecord vor:recordList){
				personcount++;
				total=ArithUtil.add(total,vor.getMoney());
			}
			objectR.put("personcount", personcount);
			objectR.put("total", total);
			object.put("zjfGoodsActivity", vo);
			object.put("zjfGoodsActivityRecord",objectR);
			ary.add(object);
		}

		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据ID获取众筹、活动列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryActivityByID(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String activityId = strJsonObject.getString("activityId"); //活动ID

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (activityId == null ||activityId.equals("")) {
			resultMap.put("errmessage", "活动ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfGoodsActivity.class};
		String[] propertyNames=new String[]{"zjfGoodsActivity.activityId", "zjfGoodsActivity.disabledState"};
		Object[] values=new String[]{activityId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;
		List<ZjfGoodsActivity> dataList = zjfGoodsActivityDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(dataList==null||dataList.size()<=0){
			resultMap.put("errmessage", "未找到对应的活动信息");
			return JSON.toJSONString(resultMap);
		}
		if(dataList.size()>1){
			resultMap.put("errmessage", "符合条件的活动信息有多条，请联系客服人员");
			return JSON.toJSONString(resultMap);
		}
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		object=new JSONObject();
		JSONObject objectR=new JSONObject();
		int personcount=0;
		double total=0;
		pojos = new Class[]{ZjfGoodsActivityRecord.class};
		propertyNames=new String[]{"zjfGoodsActivityRecord.activityId", "zjfGoodsActivityRecord.disabledState"};
		values=new String[]{activityId,"0"};
		List<ZjfGoodsActivityRecord> recordList = zjfGoodsActivityRecordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		for(ZjfGoodsActivityRecord vor:recordList){
			personcount++;
			total=ArithUtil.add(total,vor.getMoney());
		}
		objectR.put("personcount", personcount);
		objectR.put("total", total);

		object.put("zjfGoodsActivity", dataList.get(0));
		object.put("zjfGoodsActivityRecord",objectR);
		ary.add(object);
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 发起祈福 创建祈福信息
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public synchronized  String  saveCliffordInfo(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String goodsId = strJsonObject.getString("goodsId"); //商品ID
		String openId = strJsonObject.getString("openId"); //微信用户ID
		String owner_price = strJsonObject.getString("owner_price"); //用户自定义单价
		//		String cliffordName = strJsonObject.getString("cliffordName"); //被祈福人

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (goodsId == null ||goodsId.equals("")) {
			resultMap.put("errmessage", "商品ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		//		if (cliffordName == null ||cliffordName.equals("")) {
		//			resultMap.put("errmessage", "被祈福人不能为空");
		//			return JSON.toJSONString(resultMap);
		//		}
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (owner_price == null ||owner_price.equals("")) {
			resultMap.put("errmessage", "用户自定义单人单价不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfGood.class};
		String[] propertyNames=new String[]{ "zjfGood.goodsId","zjfGood.disabledState"};
		Object[] values=new String[]{goodsId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<ZjfGood> dataList  = zjfGoodsDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(dataList==null||dataList.size()<=0){
			resultMap.put("errmessage", "未找到符合的商品记录");
			return JSON.toJSONString(resultMap);
		}
		if(dataList.size()>1){
			resultMap.put("errmessage", "符合的商品记录有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfGood goods=dataList.get(0);
		BigDecimal goodsPrice=goods.getGoodsStorePrice();
		BigDecimal cliffordPrice=new BigDecimal(owner_price);
		int count=Integer.valueOf(goodsPrice.divide(cliffordPrice, 0, BigDecimal.ROUND_UP)+"");
		if(count<=0){
			resultMap.put("errmessage", "单人祈福金额不正确，请重新输入");
			return JSON.toJSONString(resultMap);
		}
		ZjfClifford zjfClifford=new ZjfClifford();
		/*
		 *保存祈福记录 
		 */
		String cliffordId=RandomCode.makeCode();
		zjfClifford.setClifford_Id(cliffordId);
		zjfClifford.setGoodsId(goodsId);
		zjfClifford.setGoodsName(goods.getGoodsName());
		zjfClifford.setUser_webchat_openID(openId);

		zjfClifford.setGoodsPrice(goodsPrice);
		zjfClifford.setCliffordPrice(cliffordPrice);
		zjfClifford.setCliffordAllNumber(count);
		//		zjfClifford.setCliffordForWhom(cliffordName);
		zjfClifford.setCliffordDidNumber(0);
		zjfClifford.setCliffordDidPercent("0");
		zjfClifford.setCliffordNeedNumber(count);
		zjfClifford.setVliffordShared(1);
		zjfClifford.setCliffordSharedTime(DateTime.getDateTime());
		zjfClifford.setCliffordStartedTime(DateTime.getDateTime());
		zjfClifford.setCliffordState(1);
		zjfClifford.setCreateTime(DateTime.getDateTime());
		zjfClifford.setCreateUser(openId);
		zjfClifford.setDisabledState(0);
		zjfCliffordDAO.save(zjfClifford);
		/*
		 * 查询是否有可兑换的祈福记录
		 */

		//		pojos = new Class[]{ZjfCliffordRecord.class};
		//		propertyNames=new String[]{"zjfCliffordRecord.is_used","zjfCliffordRecord.disabledState","zjfCliffordRecord.is_system","zjfCliffordRecord.user_webchat_openID"};
		//		values=new String[]{"0","0","1",openId};
		//
		//		List<ZjfCliffordRecord> zjfCliffordRecordList = zjfCliffordRecordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		//		if(zjfCliffordRecordList!=null&&zjfCliffordRecordList.size()>0){
		//			int system_count=0;
		//			if(zjfCliffordRecordList.size()>18){
		//				system_count=18;
		//			}else {
		//				system_count=zjfCliffordRecordList.size();
		//			}
		//			//迭代遍历所有条目，放到map里
		////			int cliffordDidNumber=zjfClifford.getCliffordDidNumber();
		////			int cliffordNeedNumber=zjfClifford.getCliffordNeedNumber();
		////			int cliffordAllNumber=zjfClifford.getCliffordAllNumber();
		//			ZjfCliffordRecord oldzjfCliffordRecord;
		//			for(int i=0;i< system_count;i++){
		//				oldzjfCliffordRecord=zjfCliffordRecordList.get(i);
		//				int number=zjfClifford.getCliffordDidNumber()+1;
		//				int need_number=zjfClifford.getCliffordNeedNumber()-1;
		//				double percent=ArithUtil.mul(ArithUtil.div(number,Double.valueOf(zjfClifford.getCliffordAllNumber()+""),2),100);
		//				/*
		//				 *修改祈福记录 
		//				 */
		//				zjfClifford.setCliffordDidNumber(number);
		//				zjfClifford.setCliffordDidPercent(percent+"");
		//				zjfClifford.setCliffordNeedNumber(need_number);
		//
		//				if(need_number<=0){
		//					zjfClifford.setCliffordState(2);
		//				}
		//
		//				zjfClifford.setUpdateTime(DateTime.getDateTime());
		//				zjfClifford.setUpdateUser(openId);
		//
		//
		//				ZjfCliffordRecord zjfCliffordRecord=new ZjfCliffordRecord();
		//				/*
		//				 *保存祈福记录 
		//				 */
		//				zjfCliffordRecord.setId(RandomCode.makeCode());
		//				zjfCliffordRecord.setCliffordRecordId(zjfClifford.getClifford_Id());
		//				zjfCliffordRecord.setUser_webchat_openID(oldzjfCliffordRecord.getUser_webchat_openID());
		////				zjfCliffordRecord.setUser_webchat_openID(openId);
		//				zjfCliffordRecord.setClifford_record_money(new BigDecimal(ArithUtil.div(oldzjfCliffordRecord.getClifford_record_money(),100,2)));
		//				zjfCliffordRecord.setCliffordRecordTime(DateTime.getDateTime());
		//
		//				zjfCliffordRecord.setClifford_record_offer(0);
		//				zjfCliffordRecord.setCliffordRecordObtain(0);
		//				zjfCliffordRecord.setOrder_num(oldzjfCliffordRecord.getOrder_num());
		//				zjfCliffordRecord.setCreateTime(DateTime.getDateTime());
		//				zjfCliffordRecord.setCreateUser(openId);
		//				zjfCliffordRecord.setDisabledState(0);
		//				zjfCliffordRecord.setTag(oldzjfCliffordRecord.getTag());
		//				zjfCliffordRecord.setTag_content(oldzjfCliffordRecord.getTag_content());
		//				zjfCliffordRecord.setIs_system(0);
		//				zjfCliffordRecord.setIs_used(1);
		//
		//				oldzjfCliffordRecord.setIs_used(1);
		//				
		//				zjfCliffordRecordDAO.save(zjfCliffordRecord);
		//				zjfCliffordDAO.update(zjfClifford);
		//				zjfCliffordRecordDAO.update(oldzjfCliffordRecord);
		//			}
		//			resultMap.put("result", Contants.CALL_RESULT_WARN);
		//			resultMap.put("errmessage", "您使用系统馈赠的月饼为您的祈福增加"+system_count+"份");
		//			resultMap.put("cliffordId", cliffordId);
		//			return JSON.toJSONString(resultMap);
		//		}

		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("cliffordId", cliffordId);
		return JSON.toJSONString(resultMap);
	}
	private synchronized ZjfClifford makeNewZjfClifford(ZjfClifford zjfClifford,String openId){
		//	祈福记录是否满  如果满 判断当前需要重新生成的人员是否有未满的祈福记录  如果有则修改 如果没有则新增

		ZjfClifford zjfClifford_new;

		Class[] 	pojos = new Class[] {ZjfClifford.class};
		String[] propertyNames=new String[]{"zjfClifford.user_webchat_openID", "zjfClifford.disabledState","zjfClifford.cliffordState"};
		Object[] values=new String[]{zjfClifford.getUser_webchat_openID(),"0","1"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;

		List<ZjfClifford> zjfCliffordList = zjfCliffordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(zjfCliffordList!=null&&zjfCliffordList.size()>0){
			/*
			 *修改祈福记录 
			 */
			zjfClifford_new=zjfCliffordList.get(0);
			//			int number=zjfClifford_new.getCliffordDidNumber()+1;
			//			int need_number=zjfClifford_new.getCliffordNeedNumber()-1;
			//
			//			double percent=ArithUtil.mul(ArithUtil.div(number,Double.valueOf(zjfClifford_new.getCliffordAllNumber()+""),2),100);
			//			/*
			//			 *修改祈福记录 
			//			 */
			//			zjfClifford_new.setCliffordDidNumber(number);
			//			zjfClifford_new.setCliffordDidPercent(percent+"");
			//			zjfClifford_new.setCliffordNeedNumber(need_number);
			//
			//			if(need_number<=0){
			//				zjfClifford_new.setCliffordState(2);
			//			}
			//
			//			zjfClifford_new.setUpdateTime(DateTime.getDateTime());
			//			zjfClifford_new.setUpdateUser(openId);
			//			zjfCliffordDAO.update(zjfClifford_new);
		}else {

			zjfClifford_new=new ZjfClifford();
			/*
			 *保存新祈福记录 
			 */
			zjfClifford_new.setClifford_Id(RandomCode.makeCode());
			zjfClifford_new.setGoodsId(zjfClifford.getGoodsId());
			zjfClifford_new.setGoodsName(zjfClifford.getGoodsName());
			//			zjfClifford_new.setUser_webchat_openID(openId);
			zjfClifford_new.setUser_webchat_openID(zjfClifford.getUser_webchat_openID());

			zjfClifford_new.setGoodsPrice(zjfClifford.getGoodsPrice());
			zjfClifford_new.setCliffordPrice(zjfClifford.getCliffordPrice());
			zjfClifford_new.setCliffordAllNumber(zjfClifford.getCliffordAllNumber());
			zjfClifford_new.setCliffordForWhom("");
			zjfClifford_new.setCliffordDidNumber(0);
			zjfClifford_new.setCliffordDidPercent("0");
			zjfClifford_new.setCliffordNeedNumber(zjfClifford.getCliffordAllNumber());

			zjfClifford_new.setVliffordShared(1);
			zjfClifford_new.setCliffordSharedTime(DateTime.getDateTime());
			zjfClifford_new.setCliffordStartedTime(DateTime.getDateTime());
			zjfClifford_new.setCliffordState(1);
			zjfClifford_new.setCreateTime(DateTime.getDateTime());
			zjfClifford_new.setCreateUser(openId);
			zjfClifford_new.setDisabledState(0);
			zjfCliffordDAO.save(zjfClifford_new);
		}

		return zjfClifford_new;
	}
	/**
	 * 记录祈福人祈福记录
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public synchronized  String  saveCliffordRecord(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String clifford_id = strJsonObject.getString("clifford_id"); //祈福表ID
		String openId = strJsonObject.getString("openId"); //微信用户ID
		String money = strJsonObject.getString("money"); //支付金额
		String tag = strJsonObject.getString("tag"); //标签
		String tag_content = strJsonObject.getString("tag_content"); //祝福话
		String order_num = strJsonObject.getString("order_num"); //支付订单
		String time = strJsonObject.getString("time"); //支付订单时间
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (clifford_id == null ||clifford_id.equals("")) {
			resultMap.put("errmessage", "祈福标识不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (money == null ||money.equals("")) {
			resultMap.put("errmessage", "支付金额不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (tag == null ||tag.equals("")) {
			resultMap.put("errmessage", "祈福人标签不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (tag_content == null ||tag_content.equals("")) {
			resultMap.put("errmessage", "祈福人祝福语不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (order_num == null ||order_num.equals("")) {
			resultMap.put("errmessage", "支付订单号不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfClifford.class};
		String[] propertyNames=new String[]{ "zjfClifford.clifford_Id","zjfClifford.disabledState"};
		Object[] values=new String[]{clifford_id,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<ZjfClifford> dataList  = zjfCliffordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(dataList==null||dataList.size()<=0){
			resultMap.put("errmessage", "未找到符合的祈福记录");
			return JSON.toJSONString(resultMap);
		}
		if(dataList.size()>1){
			resultMap.put("errmessage", "符合的祈福记录有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		pojos =new Class[] {ZjfCliffordRecord.class};
		propertyNames=new String[]{ "zjfCliffordRecord.order_num"};
		values=new String[]{order_num};

		List<ZjfCliffordRecord> record  = zjfCliffordRecordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(record!=null&&record.size()>0){
			resultMap.put("result", Contants.CALL_RESULT_SUCC);
			resultMap.put("errmessage", "已处理的记录");
			return JSON.toJSONString(resultMap);
		}

		/*
		 * 查询是否有祈福记录
		 * 祈福记录是否满  如果满 判断当前需要重新生成的人员是否有未满的祈福记录  如果有则修改 如果没有则新增
		 */

		ZjfClifford zjfClifford=dataList.get(0);

		if(zjfClifford.getCliffordNeedNumber()<=0){
			zjfClifford=makeNewZjfClifford(zjfClifford,openId);
			//			resultMap.put("errmessage", "该祈福已满，无法继续祈福");
			//			return JSON.toJSONString(resultMap);
		}
		switch (zjfClifford.getCliffordState()) {
		case 2:
			zjfClifford=makeNewZjfClifford(zjfClifford,openId);
			break;
			//			resultMap.put("errmessage", "该祈福已满，无法继续祈福");
			//			return JSON.toJSONString(resultMap);
		case 3:
			zjfClifford=makeNewZjfClifford(zjfClifford,openId);
			break;
			//			resultMap.put("errmessage", "该祈福物品已在物流运输中，无法继续祈福");
			//			return JSON.toJSONString(resultMap);
		case 4:
			zjfClifford=makeNewZjfClifford(zjfClifford,openId);
			break;
			//			resultMap.put("errmessage", "该祈福已暂停，无法继续祈福");
			//			return JSON.toJSONString(resultMap);
		case 5:
			zjfClifford=makeNewZjfClifford(zjfClifford,openId);
			break;
			//			resultMap.put("errmessage", "该祈福已终止，无法继续祈福");
			//			return JSON.toJSONString(resultMap);
		case 6:
			zjfClifford=makeNewZjfClifford(zjfClifford,openId);
			break;
			//			resultMap.put("errmessage", "该祈福物品已收货，无法继续祈福");
			//			return JSON.toJSONString(resultMap);
		case 7:
			zjfClifford=makeNewZjfClifford(zjfClifford,openId);
			break;
			//			resultMap.put("errmessage", "该祈福已删除，无法继续祈福");
			//			return JSON.toJSONString(resultMap);
		case 8:
			zjfClifford=makeNewZjfClifford(zjfClifford,openId);
			break;
			//			resultMap.put("errmessage", "该祈福物品已在发货中，无法继续祈福");
			//			return JSON.toJSONString(resultMap);
		default:
			break;
		}
		if(zjfClifford==null){
			resultMap.put("errmessage", "灵犀信息不正确,无法继续灵犀一下");
			return JSON.toJSONString(resultMap);
		}

		int number=zjfClifford.getCliffordDidNumber()+1;
		int need_number=zjfClifford.getCliffordNeedNumber()-1;

		double percent=ArithUtil.mul(ArithUtil.div(number,Double.valueOf(zjfClifford.getCliffordAllNumber()+""),2),100);
		/*
		 *修改祈福记录 
		 */
		zjfClifford.setCliffordDidNumber(number);
		zjfClifford.setCliffordDidPercent(percent+"");
		zjfClifford.setCliffordNeedNumber(need_number);

		if(need_number<=0){
			zjfClifford.setCliffordState(2);
		}

		zjfClifford.setUpdateTime(DateTime.getDateTime());
		zjfClifford.setUpdateUser(openId);


		zjfCliffordDAO.update(zjfClifford);

		ZjfCliffordRecord zjfCliffordRecord=new ZjfCliffordRecord();
		/*
		 *保存祈福记录 
		 */
		zjfCliffordRecord.setId(RandomCode.makeCode());
		zjfCliffordRecord.setCliffordRecordId(zjfClifford.getClifford_Id());
		zjfCliffordRecord.setUser_webchat_openID(openId);
		zjfCliffordRecord.setClifford_record_money(new BigDecimal(ArithUtil.div(Double.valueOf(money),100)));
		if(StringUtil.isNullOrEmpty(time)){
			zjfCliffordRecord.setCliffordRecordTime(DateTime.getDateTime());
		}else {
			zjfCliffordRecord.setCliffordRecordTime(DateUtil.StringDateFormat(time,DateUtil.yyyyMMddHHmmss,DateUtil.yyyy_MM_dd_HHmmss));
		}

		zjfCliffordRecord.setClifford_record_offer(0);
		zjfCliffordRecord.setCliffordRecordObtain(0);
		zjfCliffordRecord.setOrder_num(order_num);
		zjfCliffordRecord.setCreateTime(DateTime.getDateTime());
		zjfCliffordRecord.setCreateUser(openId);
		zjfCliffordRecord.setDisabledState(0);
		zjfCliffordRecord.setTag(tag);
		zjfCliffordRecord.setTag_content(tag_content);
		zjfCliffordRecord.setIs_system(0);
		zjfCliffordRecord.setIs_used(1);

		zjfCliffordRecordDAO.save(zjfCliffordRecord);

		pojos = new Class[] {ZjfClifford.class};
		propertyNames=new String[]{"zjfClifford.user_webchat_openID", "zjfClifford.disabledState","zjfClifford.cliffordState"};
		values=new String[]{openId,"0","1"};


		List<ZjfClifford> zjfCliffordList = zjfCliffordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		ZjfCliffordRecord zjfCliffordSystem=new ZjfCliffordRecord();
		if(zjfCliffordList!=null&&zjfCliffordList.size()>0){
			ZjfClifford zjfClifford_system=zjfCliffordList.get(0);

			int number_system=zjfClifford_system.getCliffordDidNumber()+1;
			int need_number_system=zjfClifford_system.getCliffordNeedNumber()-1;

			double percent_system=ArithUtil.mul(ArithUtil.div(number_system,Double.valueOf(zjfClifford_system.getCliffordAllNumber()+""),2),100);
			/*
			 *修改祈福记录 
			 */
			zjfClifford_system.setCliffordDidNumber(number_system);
			zjfClifford_system.setCliffordDidPercent(percent_system+"");
			zjfClifford_system.setCliffordNeedNumber(need_number_system);

			if(need_number_system<=0){
				zjfClifford_system.setCliffordState(2);
			}

			zjfClifford_system.setUpdateTime(DateTime.getDateTime());
			zjfClifford_system.setUpdateUser(openId);
			zjfCliffordDAO.update(zjfClifford_system);
			/*
			 *保存祈福记录 
			 */
			zjfCliffordSystem.setId(RandomCode.makeCode());
			zjfCliffordSystem.setCliffordRecordId(zjfClifford_system.getClifford_Id());
			zjfCliffordSystem.setUser_webchat_openID(zjfClifford.getUser_webchat_openID());
			//			zjfCliffordSystem.setUser_webchat_openID(openId);
			//		zjfCliffordSystem.setUser_webchat_openID("system");
			zjfCliffordSystem.setClifford_record_money(new BigDecimal(ArithUtil.div(Double.valueOf(money),100)));
			zjfCliffordSystem.setCliffordRecordTime(DateTime.getDateTime());
			zjfCliffordSystem.setClifford_record_offer(0);
			zjfCliffordSystem.setCliffordRecordObtain(0);
			zjfCliffordSystem.setOrder_num("system");
			zjfCliffordSystem.setCreateTime(DateTime.getDateTime());
			zjfCliffordSystem.setCreateUser("system");
			zjfCliffordSystem.setDisabledState(0);
			zjfCliffordSystem.setTag(tag);
			zjfCliffordSystem.setTag_content(querySystemContent(tag,tag_content));
			zjfCliffordSystem.setIs_system(0);
			zjfCliffordSystem.setIs_used(0);
			zjfCliffordRecordDAO.save(zjfCliffordSystem);

		}else {
			ZjfClifford zjfClifford_system=new ZjfClifford();
			/*
			 *保存祈福记录 
			 */
			String cliffordId_system=RandomCode.makeCode();
			zjfClifford_system.setClifford_Id(cliffordId_system);
			zjfClifford_system.setGoodsId(zjfClifford.getGoodsId());
			zjfClifford_system.setGoodsName(zjfClifford.getGoodsName());
			zjfClifford_system.setUser_webchat_openID(openId);

			zjfClifford_system.setGoodsPrice(zjfClifford.getGoodsPrice());
			zjfClifford_system.setCliffordPrice(zjfClifford.getCliffordPrice());
			zjfClifford_system.setCliffordAllNumber(zjfClifford.getCliffordAllNumber());
			zjfClifford_system.setCliffordForWhom("");
			//			zjfClifford_system.setCliffordForWhom(cliffordName);
			int number_system=1;
			int need_number_system=zjfClifford.getCliffordAllNumber()-1;

			double percent_system=ArithUtil.mul(ArithUtil.div(number_system,Double.valueOf(zjfClifford.getCliffordAllNumber()+""),2),100);
			/*
			 *修改祈福记录 
			 */
			zjfClifford_system.setCliffordDidNumber(number_system);
			zjfClifford_system.setCliffordDidPercent(percent_system+"");
			zjfClifford_system.setCliffordNeedNumber(need_number_system);

			zjfClifford_system.setVliffordShared(1);
			zjfClifford_system.setCliffordSharedTime(DateTime.getDateTime());
			zjfClifford_system.setCliffordStartedTime(DateTime.getDateTime());
			zjfClifford_system.setCliffordState(1);
			zjfClifford_system.setCreateTime(DateTime.getDateTime());
			zjfClifford_system.setCreateUser(openId);
			zjfClifford_system.setDisabledState(0);
			zjfCliffordDAO.save(zjfClifford_system);

			/*
			 *保存祈福记录 
			 */
			zjfCliffordSystem.setId(RandomCode.makeCode());
			zjfCliffordSystem.setCliffordRecordId(cliffordId_system);
			zjfCliffordSystem.setUser_webchat_openID(zjfClifford.getUser_webchat_openID());
			//			zjfCliffordSystem.setUser_webchat_openID(openId);
			//		zjfCliffordSystem.setUser_webchat_openID("system");
			zjfCliffordSystem.setClifford_record_money(new BigDecimal(ArithUtil.div(Double.valueOf(money),100)));
			zjfCliffordSystem.setCliffordRecordTime(DateTime.getDateTime());
			zjfCliffordSystem.setClifford_record_offer(0);
			zjfCliffordSystem.setCliffordRecordObtain(0);
			zjfCliffordSystem.setOrder_num("system");
			zjfCliffordSystem.setCreateTime(DateTime.getDateTime());
			zjfCliffordSystem.setCreateUser("system");
			zjfCliffordSystem.setDisabledState(0);
			zjfCliffordSystem.setTag(tag);
			zjfCliffordSystem.setTag_content(querySystemContent(tag,tag_content));
			zjfCliffordSystem.setIs_system(0);
			zjfCliffordSystem.setIs_used(0);
			zjfCliffordRecordDAO.save(zjfCliffordSystem);

		}


		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	private String querySystemContent(String tag,String tag_content){
		Class[] pojos = {ZjfBlessingLanguage.class};
		//是否显示 1显示 0 不显示
		String[] propertyNames=new String[]{ "disabledState","labelId"};
		Object[] values=new String[]{"0",tag};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfBlessingLanguage> zjfBlessingLanguageLizt = zjfBlessDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		if(zjfBlessingLanguageLizt!=null&&zjfBlessingLanguageLizt.size()>0){
			Random rand = new Random();
			int i = rand.nextInt(); //int范围类的随机数
			i = rand.nextInt((zjfBlessingLanguageLizt.size()-1)); 
			tag_content=zjfBlessingLanguageLizt.get(i).getBlessId();
		}
		return tag_content;
	}
	/**
	 * 根据用户openId获取已祈福列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryCliffordListByOpenId(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //用户微信openId
		String status = strJsonObject.getString("status"); //祈福状态1  进行中 2完成 3已兑换
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "用户微信账号不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (status == null ||status.equals("")) {
			resultMap.put("errmessage", "祈福状态不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfClifford.class,ZjfGood.class};
		String[] propertyNames=new String[]{"zjfClifford.user_webchat_openID", "zjfClifford.disabledState","zjfClifford.cliffordState","zjfGood.goodsId"};
		Object[] values=new String[]{openId,"0",status,"zjfClifford.goodsId"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames={"zjfClifford.cliffordStartedTime"};
		Object[] orderByValues={"ASC"};
		Integer currentPage=null;

		List<Object[]> dataList = zjfCliffordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfGood zjfGood=new ZjfGood();
			zjfGood=zjfGood.setNewObject((ZjfGood) objects[1]);
			object.put("zjfClifford",(ZjfClifford) objects[0] );
			object.put("zjfGood",zjfGood);
			ary.add(object);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据用户openId获取祈福进度及人员等
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryCliffordReocrdListByOpenId(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		//		String openId = strJsonObject.getString("openId"); //用户微信openId
		String cliffordId = strJsonObject.getString("cliffordId"); //祈福ID
		int tag = strJsonObject.getIntValue("tag"); //获取标识  0位全部获取 1 只获取用户聚福数据 2 只获取系统馈赠数据

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		//		if (openId == null ||openId.equals("")) {
		//			resultMap.put("errmessage", "用户微信账号不能为空");
		//			return JSON.toJSONString(resultMap);
		//		}
		if (cliffordId == null ||cliffordId.equals("")) {
			resultMap.put("errmessage", "祈福Id不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfClifford.class,ZjfUser.class};
		String[] propertyNames=null;
		Object[] values=null;
		//		propertyNames=new String[]{"zjfClifford.clifford_Id","zjfClifford.user_webchat_openID", "zjfClifford.disabledState"};
		//		values=new String[]{cliffordId,openId,"0"};
		propertyNames=new String[]{"zjfClifford.clifford_Id","zjfClifford.disabledState","zjfClifford.user_webchat_openID"};
		values=new String[]{cliffordId,"0","zjfUser.user_webchat_openID"};

		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<Object[]> zjfCliffordUser = zjfCliffordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		//		List<ZjfClifford> zjfClifford = zjfCliffordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);


		pojos = new Class[]{ZjfCliffordRecord.class,ZjfUser.class,ZjfLabel.class,ZjfBlessingLanguage.class};
		switch (tag) {
		case 0:
			propertyNames=new String[]{"zjfCliffordRecord.cliffordRecordId","zjfCliffordRecord.disabledState","zjfUser.user_webchat_openID","zjfLabel.labelId","zjfBlessingLanguage.blessId"};
			values=new String[]{cliffordId,"0","zjfCliffordRecord.user_webchat_openID","zjfCliffordRecord.tag","zjfCliffordRecord.tag_content"};
			break;
		case 1:
			propertyNames=new String[]{"zjfCliffordRecord.cliffordRecordId","zjfCliffordRecord.disabledState","zjfCliffordRecord.is_system","zjfUser.user_webchat_openID","zjfLabel.labelId","zjfBlessingLanguage.blessId"};
			values=new String[]{cliffordId,"0","0","zjfCliffordRecord.user_webchat_openID","zjfCliffordRecord.tag","zjfCliffordRecord.tag_content"};
			break;
		case 2:
			propertyNames=new String[]{"zjfCliffordRecord.cliffordRecordId","zjfCliffordRecord.disabledState","zjfCliffordRecord.is_system","zjfUser.user_webchat_openID","zjfLabel.labelId","zjfBlessingLanguage.blessId"};
			values=new String[]{cliffordId,"0","1","zjfCliffordRecord.user_webchat_openID","zjfCliffordRecord.tag","zjfCliffordRecord.tag_content"};
			break;
		default:
			break;
		}

		List<Object[]> dataList = zjfCliffordRecordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfUser zjfUser=new ZjfUser();
			zjfUser=zjfUser.setNewObject((ZjfUser) objects[1]);
			ZjfLabel zjfLabel=new ZjfLabel();
			zjfLabel=zjfLabel.setNewObject((ZjfLabel) objects[2]);
			ZjfBlessingLanguage zjfBlessingLanguage=new ZjfBlessingLanguage();
			zjfBlessingLanguage=zjfBlessingLanguage.setNewObject((ZjfBlessingLanguage) objects[3]);
			object.put("zjfClifford",(ZjfCliffordRecord) objects[0] );
			object.put("zjfUser",zjfUser);
			object.put("zjfLabel",zjfLabel);
			object.put("zjfBlessingLanguage",zjfBlessingLanguage);
			ary.add(object);
		}
		for(Object[] objects : zjfCliffordUser){
			object=new JSONObject();
			resultMap.put("dataBean", (ZjfClifford) objects[0]);
			resultMap.put("dataBeanUser", (ZjfUser) objects[1]);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);

		return JSON.toJSONString(resultMap);
	}
	/**
	 * 保存众筹记录
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public synchronized  String  saveActivityRecord(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String activity_id = strJsonObject.getString("activity_id"); //活动ID
		String openId = strJsonObject.getString("openId"); //微信用户ID
		String money = strJsonObject.getString("money"); //支付金额
		String order_num = strJsonObject.getString("order_num"); //支付订单
		String time = strJsonObject.getString("time"); //支付订单时间

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (activity_id == null ||activity_id.equals("")) {
			resultMap.put("errmessage", "活动标识不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (money == null ||money.equals("")) {
			resultMap.put("errmessage", "活动金额不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (order_num == null ||order_num.equals("")) {
			resultMap.put("errmessage", "支付订单号不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfGoodsActivity.class};
		String[] propertyNames=new String[]{ "zjfGoodsActivity.activityId","zjfGoodsActivity.disabledState"};
		Object[] values=new String[]{activity_id,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<ZjfGoodsActivity> dataList  = zjfGoodsActivityDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(dataList==null||dataList.size()<=0){
			resultMap.put("errmessage", "未找到符合的活动记录");
			return JSON.toJSONString(resultMap);
		}
		if(dataList.size()>1){
			resultMap.put("errmessage", "符合的活动记录有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfGoodsActivity zjfGoodsActivity=dataList.get(0);


		BigDecimal money_add = new BigDecimal(ArithUtil.div(Double.valueOf(money),100));
		BigDecimal allMoeny = zjfGoodsActivity.getActivityPrice().add(money_add);
		/*
		 *修改祈福记录 
		 */
		zjfGoodsActivity.setActivityPrice(allMoeny);

		//		if(Double.valueOf(allMoeny.toString())>=20){
		//			zjfGoodsActivity.setDiscount("9");
		//		}
		if(Double.valueOf(allMoeny.toString())>=GlobalNames.ACTIVITY_400){
			zjfGoodsActivity.setDiscount(GlobalNames.ACTIVITY_400_DISCOUNT);
		}else if(Double.valueOf(allMoeny.toString())>=GlobalNames.ACTIVITY_200){
			zjfGoodsActivity.setDiscount(GlobalNames.ACTIVITY_200_DISCOUNT);
		}else if(Double.valueOf(allMoeny.toString())>=GlobalNames.ACTIVITY_100){
			zjfGoodsActivity.setDiscount(GlobalNames.ACTIVITY_100_DISCOUNT);
		}else if(Double.valueOf(allMoeny.toString())>=GlobalNames.ACTIVITY_50){
			zjfGoodsActivity.setDiscount(GlobalNames.ACTIVITY_50_DISCOUNT);
		}

		zjfGoodsActivity.setUpdateTime(DateTime.getDateTime());
		zjfGoodsActivity.setUpdateUser(openId);


		ZjfGoodsActivityRecord zjfGoodsActivityRecord=new ZjfGoodsActivityRecord();
		/*
		 *保存众筹记录 
		 */
		zjfGoodsActivityRecord.setId(RandomCode.makeCode());
		zjfGoodsActivityRecord.setActivityId(activity_id);
		zjfGoodsActivityRecord.setOpenId(openId);
		zjfGoodsActivityRecord.setMoney( new BigDecimal(ArithUtil.div(Double.valueOf(money),100)));
		if(StringUtil.isNullOrEmpty(time)){
			zjfGoodsActivityRecord.setJoin_time(DateTime.getDateTime());
		}else {
			zjfGoodsActivityRecord.setJoin_time(DateUtil.StringDateFormat(time,DateUtil.yyyyMMddHHmmss,DateUtil.yyyy_MM_dd_HHmmss));
		}

		zjfGoodsActivityRecord.setOrder_num(order_num);
		zjfGoodsActivityRecord.setCreateTime(DateTime.getDateTime());
		zjfGoodsActivityRecord.setCreateUser(openId);
		zjfGoodsActivityRecord.setDisabledState(0);

		zjfGoodsActivityRecordDAO.save(zjfGoodsActivityRecord);
		zjfGoodsActivityDAO.update(zjfGoodsActivity);

		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据用户openId获取活动记录
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryActivityRecordListByOpenId(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //用户微信openId
		String status = strJsonObject.getString("status"); //祈福状态1  进行中 2完成
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "用户微信账号不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (status == null ||status.equals("")) {
			resultMap.put("errmessage", "活动状态不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfGoodsActivity.class,ZjfGoodsActivityRecord.class};
		String[] propertyNames=new String[]{"zjfGoodsActivityRecord.openId", "zjfGoodsActivityRecord.disabledState","zjfGoodsActivity.status","zjfGoodsActivity.disabledState","zjfGoodsActivityRecord.activityId"};
		Object[] values=new String[]{openId,"0",status,"0","zjfGoodsActivity.activityId"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<Object[]> dataList = zjfGoodsActivityDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfGoodsActivity zjfGoodsActivity=new ZjfGoodsActivity();
			zjfGoodsActivity=zjfGoodsActivity.setNewObject((ZjfGoodsActivity) objects[0]);
			object.put("zjfGoodsActivityRecord",(ZjfGoodsActivityRecord) objects[1] );
			object.put("zjfGoodsActivity",zjfGoodsActivity);
			ary.add(object);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 保存地址
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public synchronized String  saveAddress(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //用户ID
		String user_name = strJsonObject.getString("user_name"); 
		String user_address_mobile = strJsonObject.getString("user_address_mobile"); 
		String user_address = strJsonObject.getString("user_address"); 
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "用户账号不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (user_name == null ||user_name.equals("")) {
			resultMap.put("errmessage", "收货人不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (user_address_mobile == null ||user_address_mobile.equals("")) {
			resultMap.put("errmessage", "收货人联系电话不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (user_address == null ||user_address.equals("")) {
			resultMap.put("errmessage", "详细不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfUser.class};
		String[] propertyNames=new String[]{"zjfUser.user_webchat_openID", "zjfUser.disabledState"};
		Object[] values=new String[]{openId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfUser> dataList = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		if(dataList==null||dataList.size()<=0){
			resultMap.put("errmessage", "用户不存在，无法添加地址");
			return JSON.toJSONString(resultMap);
		}

		if(dataList.size()>1){
			resultMap.put("errmessage", "用户信息异常，请联系客服");
			return JSON.toJSONString(resultMap);
		}
		ZjfUserAddress zjfUserAddress=new ZjfUserAddress();
		zjfUserAddress.setUserAddressId(RandomCode.makeCode());
		zjfUserAddress.setUserId(dataList.get(0).getUserId());
		zjfUserAddress.setUserAddress(user_address);
		zjfUserAddress.setUserAddressMobile(user_address_mobile);
		zjfUserAddress.setUserName(user_name);
		zjfUserAddress.setCreateTime(DateTime.getDateTime());
		zjfUserAddress.setCreateUser(dataList.get(0).getUserId());
		zjfUserAddress.setDisabledState(0);

		zjfUserAddressDAO.save(zjfUserAddress);

		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 获取地址列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryAddressList(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //用户微信openId
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "用户微信账号不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfUser.class};
		String[] propertyNames=new String[]{"zjfUser.user_webchat_openID", "zjfUser.disabledState"};
		Object[] values=new String[]{openId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfUser> dataList = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		if(dataList==null||dataList.size()<=0){
			resultMap.put("errmessage", "用户不存在，无法添加地址");
			return JSON.toJSONString(resultMap);
		}

		if(dataList.size()>1){
			resultMap.put("errmessage", "用户信息异常，请联系客服");
			return JSON.toJSONString(resultMap);
		}

		pojos = new Class[]{ZjfUserAddress.class};
		propertyNames=new String[]{"zjfUserAddress.userId", "zjfUserAddress.disabledState"};
		values=new String[]{dataList.get(0).getUserId(),"0"};
		List<ZjfUserAddress> addressList = zjfUserAddressDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		//迭代遍历所有条目，放到map里
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", addressList);
		return JSON.toJSONString(resultMap);
	}
	/**
	 *保存用户
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public synchronized String  saveWeixinUser(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //用户ID
		String nickname = strJsonObject.getString("nickname"); 
		int sex = strJsonObject.getIntValue("sex"); 
		String country = strJsonObject.getString("country"); 
		String province = strJsonObject.getString("province"); 

		String city = strJsonObject.getString("city"); 
		String headImgUrl = strJsonObject.getString("headImgUrl"); 
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "用户账号不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfUser.class};
		String[] propertyNames=new String[]{"zjfUser.user_webchat_openID", "zjfUser.disabledState"};
		Object[] values=new String[]{openId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfUser> dataList = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(dataList.size()>1){
			resultMap.put("errmessage", "用户信息异常，请联系客服");
			return JSON.toJSONString(resultMap);
		}
		if(dataList==null||dataList.size()<=0){

			ZjfUser zjfUser=new ZjfUser();
			zjfUser.setUserId(RandomCode.makeCode());
			zjfUser.setUserName(nickname);
			zjfUser.setUserSex(sex);
			zjfUser.setUserCountry(country);
			zjfUser.setUserCity(city);
			zjfUser.setUserProvince(province);
			zjfUser.setUser_webchat_openID(openId);
			zjfUser.setUserWebcahtHeadurl(headImgUrl);
			zjfUser.setCreateTime(DateTime.getDateTime());
			zjfUser.setCreateUser(openId);
			zjfUser.setDisabledState(0);
			zjfUser.setUserPoInt(0);
			zjfUser.setUserBalance(new BigDecimal(0));
			zjfUser.setUserGoodsValues(0);
			zjfUser.setUserReginsterTime(DateTime.getDateTime());
			zjfUser.setUserLastLogin(DateTime.getDateTime());
			zjfUserDAO.save(zjfUser);
		}else {
			ZjfUser zjfUser=dataList.get(0);
			zjfUser.setUserName(nickname);
			zjfUser.setUserSex(sex);
			zjfUser.setUserCountry(country);
			zjfUser.setUserCity(city);
			zjfUser.setUserProvince(province);
			zjfUser.setUser_webchat_openID(openId);
			zjfUser.setUserWebcahtHeadurl(headImgUrl);
			zjfUser.setUpdateTime(DateTime.getDateTime());
			zjfUser.setUpdateUser(openId);
			zjfUser.setDisabledState(0);
			zjfUser.setUserLastLogin(DateTime.getDateTime());
			zjfUserDAO.save(zjfUser);
		}


		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 查询印象标签列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160802
	 */
	public String  queryLable(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);

		Class[] pojos = {ZjfLabel.class};
		//是否显示 1显示 0 不显示
		String[] propertyNames=new String[]{ "disabledState"};
		Object[] values=new String[]{"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfLabel> zjfLabelLizt = zjfLabelDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", zjfLabelLizt);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 查询印象标签留言
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160803
	 */
	public String  queryMessage(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);
		String tagId = strJsonObject.getString("tagId"); //标签ID
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (tagId == null ||tagId.equals("")) {
			resultMap.put("errmessage", "标签不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfBlessingLanguage.class};
		//是否显示 1显示 0 不显示
		String[] propertyNames=new String[]{ "disabledState","labelId"};
		Object[] values=new String[]{"0",tagId};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfBlessingLanguage> zjfBlessingLanguageLizt = zjfBlessDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", zjfBlessingLanguageLizt);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 查询用户信息
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160802
	 */
	public String  queryUserInfo(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);
		String openId = strJsonObject.getString("openId"); //用户ID
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "用户账号不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfUser.class};
		String[] propertyNames=new String[]{ "disabledState","user_webchat_openID"};
		Object[] values=new String[]{"0",openId};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfUser> zjfUserLizt = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", zjfUserLizt);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 修改用户信息
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160802
	 */
	public synchronized String  updateUserInfo(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);
		String openId = strJsonObject.getString("openId"); //用户ID
		String userName = strJsonObject.getString("userName"); //用户userName
		String userMobile = strJsonObject.getString("userMobile"); //用户userMobile
		String userAddress = strJsonObject.getString("userAddress"); //用户userAddress
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "用户账号不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfUser.class};
		String[] propertyNames=new String[]{ "disabledState","user_webchat_openID"};
		Object[] values=new String[]{"0",openId};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfUser> zjfUserLizt = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);


		if(zjfUserLizt==null||zjfUserLizt.size()<=0){
			resultMap.put("errmessage", "未找到用户信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfUserLizt.size()>1){
			resultMap.put("errmessage", "符合的用户信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfUser zjfUser=zjfUserLizt.get(0);
		zjfUser.setUserName(userName);
		zjfUser.setUserMobile(userMobile);
		zjfUser.setUserAddress(userAddress);
		zjfUser.setUpdateTime(DateTime.getDateTime());
		zjfUser.setUpdateUser(openId);
		zjfUserDAO.update(zjfUser);

		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 查询祈福详细
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160803
	 */
	public String  queryCliffordDetail(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);
		String cliffordId = strJsonObject.getString("cliffordId"); //祈福ID
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (cliffordId == null ||cliffordId.equals("")) {
			resultMap.put("errmessage", "祈福ID不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfClifford.class};
		String[] propertyNames=new String[]{ "disabledState","clifford_Id"};
		Object[] values=new String[]{"0",cliffordId};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;

		List<ZjfClifford> zjfCliffordLizt = zjfCliffordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);


		if(zjfCliffordLizt==null||zjfCliffordLizt.size()<=0){
			resultMap.put("errmessage", "未找到祈福信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfCliffordLizt.size()>1){
			resultMap.put("errmessage", "符合的祈福记录有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfClifford ZjfClifford=zjfCliffordLizt.get(0);

		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("zjfClifford", ZjfClifford);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据ID获取众筹、活动列表 ---麦道
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160721
	 */
	public String  queryActivityByCake(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		String openId = strJsonObject.getString("openId"); //用户微信openId
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "用户微信账号不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos = {ZjfGoodsActivity.class};
		String[] propertyNames=new String[]{"zjfGoodsActivity.disabledState"};
		Object[] values=new String[]{"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;
		Integer currentPage=null;
		List<ZjfGoodsActivity> dataList = zjfGoodsActivityDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(dataList==null||dataList.size()<=0){
			resultMap.put("errmessage", "未找到对应的活动信息");
			return JSON.toJSONString(resultMap);
		}
		//		if(dataList.size()>1){
		//			resultMap.put("errmessage", "符合条件的活动信息有多条，请联系客服人员");
		//			return JSON.toJSONString(resultMap);
		//		}
		ZjfGoodsActivity zjfGoodsActivity=dataList.get(0);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		object=new JSONObject();
		JSONObject objectR=new JSONObject();
		int personcount=0;
		double total=0;
		pojos = new Class[]{ZjfGoodsActivityRecord.class};
		propertyNames=new String[]{"zjfGoodsActivityRecord.activityId", "zjfGoodsActivityRecord.disabledState"};
		values=new String[]{zjfGoodsActivity.getActivityId(),"0"};
		List<ZjfGoodsActivityRecord> recordList = zjfGoodsActivityRecordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		for(ZjfGoodsActivityRecord vor:recordList){
			personcount++;
			total=ArithUtil.add(total,vor.getMoney());
		}
		objectR.put("personcount", personcount);
		objectR.put("total", total);

		object.put("zjfGoodsActivity", dataList.get(0));
		object.put("zjfGoodsActivityRecord",objectR);

		JSONObject objectRU=new JSONObject();
		double totalRU=0;
		pojos = new Class[]{ZjfGoodsActivityRecord.class};
		propertyNames=new String[]{"zjfGoodsActivityRecord.activityId", "zjfGoodsActivityRecord.disabledState", "zjfGoodsActivityRecord.openId"};
		values=new String[]{zjfGoodsActivity.getActivityId(),"0",openId};
		List<ZjfGoodsActivityRecord> recordListRu = zjfGoodsActivityRecordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		for(ZjfGoodsActivityRecord vor:recordListRu){
			totalRU=ArithUtil.add(totalRU,vor.getMoney());
		}
		objectRU.put("personmoney", totalRU);

		object.put("zjfGoodsActivityRecordUser",objectRU);
		ary.add(object);

		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 根据用户openId查询我的聚福记录列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160806
	 */
	public String  queryMyCliffordRecordList(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //用户微信openId
		String status = strJsonObject.getString("status"); //祈福状态1  未兑换 2 已兑换
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "用户微信账号不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (status == null ||status.equals("")) {
			resultMap.put("errmessage", "兑换状态不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfCliffordRecord.class,ZjfLabel.class,ZjfBlessingLanguage.class,ZjfClifford.class,ZjfUser.class};

		String[] propertyNames=null;
		Object[] values=null;
		propertyNames=new String[]{"zjfCliffordRecord.is_used","zjfCliffordRecord.disabledState","zjfCliffordRecord.is_system",
				"zjfCliffordRecord.user_webchat_openID","zjfCliffordRecord.tag","zjfCliffordRecord.tag_content"
				,"zjfCliffordRecord.cliffordRecordId","zjfClifford.user_webchat_openID"};
		if("1".equals(status)){
			values=new String[]{"0","0","1",openId,"zjfLabel.labelId","zjfBlessingLanguage.blessId","zjfClifford.clifford_Id","zjfUser.user_webchat_openID"};
		}else  if("2".equals(status)){
			values=new String[]{"1","0","1",openId,"zjfLabel.labelId","zjfBlessingLanguage.blessId","zjfClifford.clifford_Id","zjfUser.user_webchat_openID"};
		}
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames={"zjfCliffordRecord.cliffordRecordTime"};
		Object[] orderByValues={"ASC"};
		Integer currentPage=null;

		List<Object[]> dataList = zjfCliffordRecordDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		JSONArray ary=new JSONArray();
		JSONObject object;
		//迭代遍历所有条目，放到map里
		for(Object[] objects : dataList){
			object=new JSONObject();
			ZjfLabel zjfLabel=new ZjfLabel();
			zjfLabel=zjfLabel.setNewObject((ZjfLabel) objects[1]);
			ZjfBlessingLanguage zjfBlessingLanguage=new ZjfBlessingLanguage();
			zjfBlessingLanguage=zjfBlessingLanguage.setNewObject((ZjfBlessingLanguage) objects[2]);
			//			ZjfClifford zjfClifford=new ZjfClifford();
			//			zjfClifford=zjfClifford.setNewObject((ZjfClifford) objects[3]);
			ZjfUser zjfUser=new ZjfUser();
			zjfUser=zjfUser.setNewObject((ZjfUser) objects[4]);
			object.put("zjfCliffordRecord",(ZjfCliffordRecord) objects[0] );
			object.put("zjfLabel",zjfLabel);
			object.put("zjfBlessingLanguage",zjfBlessingLanguage);
			//			object.put("zjfClifford",zjfClifford);
			object.put("zjfUser",zjfUser);
			ary.add(object);
		}
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", ary);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 保存、修改购物车
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160813
	 */
	public synchronized  String  saveCarInfo(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String goodsId = strJsonObject.getString("goodsId"); //商品ID
		String openId = strJsonObject.getString("openId"); //微信用户ID
		//		String userId = strJsonObject.getString("userId"); //用户ID
		int goodsCount = strJsonObject.getIntValue("goodsCount"); //商品数量
		int countType = strJsonObject.getIntValue("countType"); //商品数量操作类型  1增2 减
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (goodsId == null ||goodsId.equals("")) {
			resultMap.put("errmessage", "商品ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		//		if (userId == null ||userId.equals("")) {
		//			resultMap.put("errmessage", "用户ID不能为空");
		//			return JSON.toJSONString(resultMap);
		//		}
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (goodsCount<=0) {
			resultMap.put("errmessage", "商品数量不能少于1个");
			return JSON.toJSONString(resultMap);
		}
		if (countType!=1&&countType!=2) {
			resultMap.put("errmessage", "购物车操作类型不正确");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos = {ZjfGood.class};
		String[] propertyNames=new String[]{ "zjfGood.goodsId","zjfGood.disabledState"};
		Object[] values=new String[]{goodsId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<ZjfGood> dataList  = zjfGoodsDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(dataList==null||dataList.size()<=0){
			resultMap.put("errmessage", "未找到符合的商品记录");
			return JSON.toJSONString(resultMap);
		}
		if(dataList.size()>1){
			resultMap.put("errmessage", "符合的商品记录有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfGood goods=dataList.get(0);

		pojos =new Class[] {ZjfUser.class};
		propertyNames=new String[]{ "zjfUser.user_webchat_openID","zjfUser.disabledState"};
		values=new String[]{openId,"0"};
		List<ZjfUser> zjfUserList  = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(zjfUserList==null||zjfUserList.size()<=0){
			resultMap.put("errmessage", "未找到用户信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfUserList.size()>1){
			resultMap.put("errmessage", "符合的用户信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfUser zjfUser=zjfUserList.get(0);

		pojos =new Class[] {ZjfCarItem.class};
		propertyNames=new String[]{"zjfCarItem.userId", "zjfCarItem.goodsId","zjfCarItem.disabledState","zjfCarItem.goodsPrice"};
		values=new String[]{zjfUser.getUserId(),goodsId,"0",goods.getGoodsStorePrice()+""};
		List<ZjfCarItem> zjfCarItemList  = zjfCarItemDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(zjfCarItemList!=null&&zjfCarItemList.size()>0){
			if(zjfCarItemList.size()>1){
				resultMap.put("errmessage", "符合的购物车数据有多条，无法匹配");
				return JSON.toJSONString(resultMap);
			}
			ZjfCarItem zjfCarItem=zjfCarItemList.get(0);
			/*
			 *保存商品记录
			 */
			zjfCarItem.setGoodsName(goods.getGoodsName());
			zjfCarItem.setGoodsTypeId(goods.getGoodsClassId());
			zjfCarItem.setGoodsBn(goods.getGoodsSerial());

			int currentCount=zjfCarItem.getGoodsAmount();
			if (countType==1) {
				currentCount=goodsCount+zjfCarItem.getGoodsAmount();
			}else if(countType==2){
				if(zjfCarItem.getGoodsAmount()>=goodsCount){
					currentCount=zjfCarItem.getGoodsAmount()-goodsCount;
				}else {
					currentCount=0;
				}
			}else {
				resultMap.put("errmessage", "购物车操作类型不正确");
				return JSON.toJSONString(resultMap);
			}
			zjfCarItem.setGoodsAmount(currentCount);
			zjfCarItem.setOrderCostItem(ArithUtil.mul(currentCount, goods.getGoodsStorePrice()));

			zjfCarItem.setUpdateTime(DateTime.getDateTime());
			zjfCarItem.setUpdateUser(openId);
			if(zjfCarItem.getGoodsAmount()<=0){
				zjfCarItem.setDisabledState(1);
			}
			zjfCarItemDAO.update(zjfCarItem);
		}else {
			if (countType!=1) {
				resultMap.put("errmessage", "购物车内不包含该商品，无法修该商品数量");
				return JSON.toJSONString(resultMap);
			}
			ZjfCarItem zjfCarItem=new ZjfCarItem();
			/*
			 *保存商品记录
			 */
			zjfCarItem.setCarItemId(RandomCode.makeCode());
			zjfCarItem.setGoodsId(goodsId);
			zjfCarItem.setUserId(zjfUser.getUserId());
			zjfCarItem.setGoodsName(goods.getGoodsName());
			zjfCarItem.setGoodsTypeId(goods.getGoodsClassId());
			zjfCarItem.setGoodsBn(goods.getGoodsSerial());
			zjfCarItem.setGoodsPrice(goods.getGoodsStorePrice());
			zjfCarItem.setCarItemDlyStatus(1);
			zjfCarItem.setGoodsAmount(goodsCount);
			zjfCarItem.setOrderCostItem(ArithUtil.mul(goodsCount, goods.getGoodsStorePrice()));

			zjfCarItem.setCreateTime(DateTime.getDateTime());
			zjfCarItem.setCreateUser(openId);
			zjfCarItem.setDisabledState(0);
			zjfCarItemDAO.save(zjfCarItem);
		}


		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 获取购物车列表
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160813
	 */
	public   String  queryMyCar(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //微信用户ID
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos =new Class[] {ZjfUser.class};
		String[] propertyNames=new String[]{ "zjfUser.user_webchat_openID","zjfUser.disabledState"};
		Object[]  values=new String[]{openId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<ZjfUser> zjfUserList  = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(zjfUserList==null||zjfUserList.size()<=0){
			resultMap.put("errmessage", "未找到用户信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfUserList.size()>1){
			resultMap.put("errmessage", "符合的用户信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfUser zjfUser=zjfUserList.get(0);

		pojos =new Class[] {ZjfCarItem.class};
		propertyNames=new String[]{"zjfCarItem.userId","zjfCarItem.disabledState"};
		values=new String[]{zjfUser.getUserId(),"0"};
		List<ZjfCarItem> zjfCarItemList  = zjfCarItemDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("dataList", zjfCarItemList);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 生成订单
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160813
	 */
	public synchronized  String  saveOrderInfo(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //微信用户ID
		String orderIP = strJsonObject.getString("orderIP"); //订单生成IP
		String user_address_id = strJsonObject.getString("user_address_id"); //订单收货地址ID
		JSONArray carItemList = JSON.parseArray(strJsonObject.getString("carItemList")); //订单内购物车对应ID列表
		BigDecimal order_discount = strJsonObject.getBigDecimal("order_discount"); //折扣
		String order_memo = strJsonObject.getString("order_memo"); //纪要 备注
		JSONObject taxBean =JSON.parseObject(strJsonObject.getString("taxBean")); //发票信息 是否开发票 order_is_tax  order_cost_tax发票费率  order_tax_company发票抬头

		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (user_address_id == null ||user_address_id.equals("")) {
			resultMap.put("errmessage", "订单收货不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (carItemList == null ||carItemList.size()<=0) {
			resultMap.put("errmessage", "订单内商品列表不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (taxBean == null ||taxBean.size()<=0) {
			resultMap.put("errmessage", "订单发票信息不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos =new Class[] {ZjfUser.class};
		String[] propertyNames=new String[]{ "zjfUser.user_webchat_openID","zjfUser.disabledState"};
		Object[]  values=new String[]{openId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<ZjfUser> zjfUserList  = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(zjfUserList==null||zjfUserList.size()<=0){
			resultMap.put("errmessage", "未找到用户信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfUserList.size()>1){
			resultMap.put("errmessage", "符合的用户信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfUser zjfUser=zjfUserList.get(0);

		pojos =new Class[] {ZjfUserAddress.class};
		propertyNames=new String[]{"zjfUserAddress.userAddressId","zjfUserAddress.disabledState"};
		values=new String[]{user_address_id,"0"};
		List<ZjfUserAddress> zjfUserAddressList  = zjfUserAddressDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		if(zjfUserAddressList==null||zjfUserAddressList.size()<=0){
			resultMap.put("errmessage", "未找到收货地址信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfUserAddressList.size()>1){
			resultMap.put("errmessage", "符合的收货地址信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfUserAddress zjfUserAddress=zjfUserAddressList.get(0);

		pojos =new Class[] {ZjfCarItem.class};
		propertyNames=null;
		 values=null;
		 
		likePropertyNames=new String[carItemList.size()+1];
		likevalues=new String[carItemList.size()+1];
		for(int i=0;i<carItemList.size();i++){
			likePropertyNames[i]="zjfCarItem.carItemId";
			likevalues[i]=carItemList.getString(i);
		}
		likePropertyNames[(likePropertyNames.length-1)]="zjfCarItem.disabledState";
		likevalues[(likevalues.length-1)]="0";
	
		List<ZjfCarItem> zjfCarItemList  = zjfCarItemDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		
		if(zjfCarItemList==null||zjfCarItemList.size()<=0){
			resultMap.put("errmessage", "未找到订单商品信息");
			return JSON.toJSONString(resultMap);
		}
		/*
		 * 保存订单  保存订单商品详情
		 */
		ZjfOrder zjfOrder =new ZjfOrder();
		String orderId=RandomCode.makeCode();
		zjfOrder.setOrderId(orderId);
		zjfOrder.setUserId(zjfUser.getUserId());
		zjfOrder.setOrderStatus(1);
		zjfOrder.setOrderPayStatus(0);
		zjfOrder.setUserStatus(0);
		zjfOrder.setOrderIsDelivery(0);
		
		zjfOrder.setOrderCreatetime(DateTime.getDateTime());
		zjfOrder.setOrderIp(orderIP);
		zjfOrder.setOrderShipName(zjfUserAddress.getUserName());
		zjfOrder.setOrderShipArea(zjfUserAddress.getUserAddressArea());
		zjfOrder.setOrderShipAddr(zjfUserAddress.getUserAddress());
		zjfOrder.setOrderShipZip(zjfUserAddress.getUserAddressZipCode());
		zjfOrder.setOrderShipTel(zjfUserAddress.getUserAddressTel());
		zjfOrder.setOrderShipMobile(zjfUserAddress.getUserAddressMobile());
		 //发票信息 是否开发票 order_is_tax  order_cost_tax发票费率  order_tax_company发票抬头
		zjfOrder.setOrderIsTax(taxBean.getInteger("order_is_tax"));
		zjfOrder.setOrderCostTax(taxBean.getBigDecimal("order_is_tax"));
		zjfOrder.setOrderTaxCompany(taxBean.getString("order_tax_company"));
		zjfOrder.setOrderMemo(order_memo);
		
		BigDecimal totalBigDecimal=new BigDecimal(0);
		int totalCount=0;
		for(ZjfCarItem vo:zjfCarItemList){
			ZjfOrdersItem zjfOrdersItem =new ZjfOrdersItem();
			zjfOrdersItem.setOrderItemId(RandomCode.makeCode());
			zjfOrdersItem.setOrderId(orderId);
			zjfOrdersItem.setGoodsAmount(vo.getGoodsAmount());
			zjfOrdersItem.setGoodsBn(vo.getGoodsBn());
			zjfOrdersItem.setGoodsId(vo.getGoodsId());
			zjfOrdersItem.setGoodsName(vo.getGoodsName());
			zjfOrdersItem.setGoodsPrice(vo.getGoodsPrice());
			zjfOrdersItem.setGoodsTypeId(vo.getGoodsTypeId());
			zjfOrdersItem.setOrderCostItem(vo.getOrderCostItem());
			zjfOrdersItem.setOrderItmeDlyStatus(vo.getCarItemDlyStatus());
			
			
			zjfOrdersItem.setCreateTime(DateTime.getDateTime());
			zjfOrdersItem.setCreateUser(openId);
			zjfOrdersItem.setDisabledState(0);
			
			totalBigDecimal=totalBigDecimal.add(zjfOrdersItem.getOrderCostItem());
			totalCount=totalCount+zjfOrdersItem.getGoodsAmount();
			
			zjfOrderItemDAO.save(zjfOrdersItem);
			
			vo.setDisabledState(1);
			zjfCarItemDAO.update(vo);
		}
		zjfOrder.setOrderItemnum(totalCount);
		zjfOrder.setOrderCostItem(totalBigDecimal);//商品总共花费金额
		zjfOrder.setOrderDiscount(order_discount);//1不打折1一下是折扣
		zjfOrder.setOrderFinalAmount(totalBigDecimal.multiply(order_discount));
		zjfOrder.setOrderLastChangeTime(DateTime.getDateTime());
		zjfOrder.setCreateTime(DateTime.getDateTime());
		zjfOrder.setCreateUser(openId);
		zjfOrder.setDisabledState(0);
		zjfOrderDAO.save(zjfOrder);
		
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		resultMap.put("orderId", orderId);
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 删除订单
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160813
	 */
	public synchronized  String  deleteOrderInfo(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //微信用户ID
		String orderId = strJsonObject.getString("orderId"); //订单ID
		
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (orderId == null ||orderId.equals("")) {
			resultMap.put("errmessage", "订单ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos =new Class[] {ZjfUser.class};
		String[] propertyNames=new String[]{ "zjfUser.user_webchat_openID","zjfUser.disabledState"};
		Object[]  values=new String[]{openId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<ZjfUser> zjfUserList  = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(zjfUserList==null||zjfUserList.size()<=0){
			resultMap.put("errmessage", "未找到用户信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfUserList.size()>1){
			resultMap.put("errmessage", "符合的用户信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfUser zjfUser=zjfUserList.get(0);

		pojos =new Class[] {ZjfOrder.class};
		propertyNames=new String[]{"zjfOrder.orderId","zjfOrder.userId","zjfOrder.disabledState"};
		values=new String[]{orderId,zjfUser.getUserId(),"0"};
		List<ZjfOrder> zjfOrderList  = zjfOrderDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		if(zjfOrderList==null||zjfOrderList.size()<=0){
			resultMap.put("errmessage", "未找到订单信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfOrderList.size()>1){
			resultMap.put("errmessage", "符合的订单信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfOrder zjfOrder=zjfOrderList.get(0);
		/*
		 * 删除订单 修改订单状态 
		 */
		zjfOrder.setOrderStatus(3);
		zjfOrder.setDisabledState(1);
		zjfOrder.setUpdateTime(DateTime.getDateTime());
		zjfOrder.setUpdateUser(openId);
		zjfOrderDAO.update(zjfOrder);
		
		
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 取消订单
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160813
	 */
	public synchronized  String  cancleOrderInfo(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //微信用户ID
		String orderId = strJsonObject.getString("orderId"); //订单ID
		String paymethod = strJsonObject.getString("paymethod"); //订单退款方式 wechat微信平台退款
		
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (orderId == null ||orderId.equals("")) {
			resultMap.put("errmessage", "订单ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (paymethod == null ||paymethod.equals("")) {
			resultMap.put("errmessage", "订单退款方式不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos =new Class[] {ZjfUser.class};
		String[] propertyNames=new String[]{ "zjfUser.user_webchat_openID","zjfUser.disabledState"};
		Object[]  values=new String[]{openId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<ZjfUser> zjfUserList  = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(zjfUserList==null||zjfUserList.size()<=0){
			resultMap.put("errmessage", "未找到用户信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfUserList.size()>1){
			resultMap.put("errmessage", "符合的用户信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfUser zjfUser=zjfUserList.get(0);

		pojos =new Class[] {ZjfOrder.class};
		propertyNames=new String[]{"zjfOrder.orderId","zjfOrder.userId","zjfOrder.disabledState"};
		values=new String[]{orderId,zjfUser.getUserId(),"0"};
		List<ZjfOrder> zjfOrderList  = zjfOrderDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		if(zjfOrderList==null||zjfOrderList.size()<=0){
			resultMap.put("errmessage", "未找到订单信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfOrderList.size()>1){
			resultMap.put("errmessage", "符合的订单信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfOrder zjfOrder=zjfOrderList.get(0);
		/*
		 * 进行退款处理  查询支付订单信息在调用微信接口进行退款申请
		 */
		if(zjfOrder!=null){
			if(!StringUtil.isNullOrEmpty(zjfOrder.getOrderNum())){
				/*
				 * 查询支付记录 进行退款
				 */
				ZjfPayment zjfPayment=new ZjfPayment();
				zjfPayment.setPaymentId(RandomCode.makeCode());
				zjfPayment.setOrderId(orderId);
				zjfPayment.setPaymentMoney(zjfOrder.getOrderPayment());
				zjfPayment.setUserId(zjfUser.getUserId());
				//TODO 退款申请 以及退款订单号保存；
				zjfPayment.setPaymentMethod(paymethod);
				zjfPayment.setPaymentType(2);
				zjfPayment.setPaymentOutNoReturn("");
				zjfPayment.setPaymentTradeNoReturn("");
				zjfPayment.setCreateTime(DateTime.getDateTime());
				zjfPayment.setCreateUser(openId);
				zjfPayment.setPaymentDisabled(0);
				zjfPayment.setDisabledState(0);
				BigDecimal returnmoney=ArithUtil.mul(100,zjfOrder.getOrderPayment());//微信已分为单位 的退款金额
				boolean tag =true;
				if(tag){
					/*
					 * 保存退款记录
					 */
					zjfPayment.setPaymentStatus("succ");
					zjfPayment.setPaymentResult(1);
					zjfPayment.setPaymentMessage("");
					zjfPaymentDAO.save(zjfPayment);
				}else{
					zjfPayment.setPaymentStatus("fail");
					zjfPayment.setPaymentResult(0);
					zjfPayment.setPaymentMessage("支付方式退款失败，暂时无法取消订单");
					zjfPaymentDAO.save(zjfPayment);
					resultMap.put("result", Contants.CALL_RESULT_FAIL);
					resultMap.put("errmessage", "支付方式退款失败，暂时无法取消订单");
					return JSON.toJSONString(resultMap);
				}
			}
			/*
			 * 取消订单 修改订单状态 
			 */
			zjfOrder.setOrderStatus(4);//4  已申请退款并取消订单
			zjfOrder.setUpdateTime(DateTime.getDateTime());
			zjfOrder.setUpdateUser(openId);
			zjfOrderDAO.update(zjfOrder);
		}else {
			resultMap.put("result", Contants.CALL_RESULT_FAIL);
			resultMap.put("errmessage", "未找到订单信息");
			return JSON.toJSONString(resultMap);
		}
		
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 完成订单
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160813
	 */
	public synchronized  String  completeOrderInfo(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //微信用户ID
		String orderId = strJsonObject.getString("orderId"); //订单ID
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (orderId == null ||orderId.equals("")) {
			resultMap.put("errmessage", "订单ID不能为空");
			return JSON.toJSONString(resultMap);
		}

		Class[] pojos =new Class[] {ZjfUser.class};
		String[] propertyNames=new String[]{ "zjfUser.user_webchat_openID","zjfUser.disabledState"};
		Object[]  values=new String[]{openId,"0"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		List<ZjfUser> zjfUserList  = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(zjfUserList==null||zjfUserList.size()<=0){
			resultMap.put("errmessage", "未找到用户信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfUserList.size()>1){
			resultMap.put("errmessage", "符合的用户信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfUser zjfUser=zjfUserList.get(0);

		pojos =new Class[] {ZjfOrder.class};
		propertyNames=new String[]{"zjfOrder.orderId","zjfOrder.userId","zjfOrder.disabledState"};
		values=new String[]{orderId,zjfUser.getUserId(),"0"};
		List<ZjfOrder> zjfOrderList  = zjfOrderDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		if(zjfOrderList==null||zjfOrderList.size()<=0){
			resultMap.put("errmessage", "未找到订单信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfOrderList.size()>1){
			resultMap.put("errmessage", "符合的订单信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		ZjfOrder zjfOrder=zjfOrderList.get(0);
		/*
		 * 完成订单 修改订单状态  进行用户积分进行更新
		 */
		zjfOrder.setOrderStatus(2);
		zjfOrder.setUpdateTime(DateTime.getDateTime());
		zjfOrder.setUpdateUser(openId);
		zjfOrderDAO.update(zjfOrder);
		
		int point=1+zjfUser.getUserPoInt();
		BigDecimal add_balance=new BigDecimal(1);
		zjfUser.setUserPoInt(point);
		zjfUser.setUserBalance(add_balance.add(zjfUser.getUserBalance()));
		zjfUser.setUpdateTime(DateTime.getDateTime());
		zjfUser.setUpdateUser(openId);
		zjfUserDAO.update(zjfUser);
		
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	/**
	 * 保存订单支付记录
	 * @param strJson_para
	 * @return
	 * @throws Exception
	 * @author 李竺桐 20160813
	 */
	public synchronized  String  saveOrderPayInfo(String strJson_para) throws Exception {
		JSONObject strJsonObject = JSON.parseObject(strJson_para);

		String openId = strJsonObject.getString("openId"); //微信用户ID
		String orderId = strJsonObject.getString("orderId"); //订单ID
		String money = strJsonObject.getString("money"); //支付金额
		String payment_out_no = strJsonObject.getString("payment_out_no"); //支付商户订单号
		String payment_trade_no = strJsonObject.getString("payment_trade_no"); //支付平台订单号
		String paymethod = strJsonObject.getString("paymethod"); //支付方式 wechat  微信支付
		
		Map<String, Object> resultMap = new HashMap<String, Object>(); 
		resultMap.put("result", Contants.CALL_RESULT_FAIL);
		if (openId == null ||openId.equals("")) {
			resultMap.put("errmessage", "微信用户ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (orderId == null ||orderId.equals("")) {
			resultMap.put("errmessage", "订单ID不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (money == null ||money.equals("")) {
			resultMap.put("errmessage", "支付金额不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (payment_out_no == null ||payment_out_no.equals("")) {
			resultMap.put("errmessage", "支付商户订单号不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (payment_trade_no == null ||payment_trade_no.equals("")) {
			resultMap.put("errmessage", "支付平台订单号不能为空");
			return JSON.toJSONString(resultMap);
		}
		if (paymethod == null ||paymethod.equals("")) {
			resultMap.put("errmessage", "支付方式不能为空");
			return JSON.toJSONString(resultMap);
		}
		Class[] pojos =new Class[] {ZjfPayment.class};
		String[] propertyNames=new String[]{"zjfPayment.orderId","zjfPayment.paymentTradeNo","zjfPayment.disabledState","zjfPayment.paymentResult"};
		Object[]  values=new String[]{orderId,payment_trade_no,"0","1"};
		String[] likePropertyNames = null;
		Object[] likevalues= null;
		String[] betweenPropertyNames=null;
		Object[][]  betweenvalues=null;
		String[] orderByPropertyNames=null;
		Object[] orderByValues=null;

		orderByPropertyNames = null;
		orderByValues = null;
		Integer currentPage=null;
		
		List<ZjfPayment> zjfPaymentList  = zjfPaymentDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		if(zjfPaymentList!=null&&zjfPaymentList.size()>0){
			resultMap.put("result", Contants.CALL_RESULT_SUCC);
			resultMap.put("errmessage", "该订单已处理");
			return JSON.toJSONString(resultMap);
		}
		BigDecimal paymoneyBigDecimal=new BigDecimal(ArithUtil.div(Double.valueOf(money),100));
		ZjfPayment zjfPayment=new ZjfPayment();
		zjfPayment.setPaymentId(RandomCode.makeCode());
		zjfPayment.setOrderId(orderId);
		zjfPayment.setPaymentMoney(paymoneyBigDecimal);
		zjfPayment.setPaymentMethod(paymethod);
		zjfPayment.setPaymentType(1);
		
		zjfPayment.setPaymentOutNo(payment_out_no);
		zjfPayment.setPaymentTradeNo(payment_trade_no);
		zjfPayment.setCreateTime(DateTime.getDateTime());
		zjfPayment.setCreateUser(openId);
		zjfPayment.setPaymentDisabled(0);
		zjfPayment.setDisabledState(0);
		
		pojos =new Class[] {ZjfUser.class};
		propertyNames=new String[]{ "zjfUser.user_webchat_openID","zjfUser.disabledState"};
		values=new String[]{openId,"0"};
		List<ZjfUser> zjfUserList  = zjfUserDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);

		if(zjfUserList==null||zjfUserList.size()<=0){
			zjfPayment.setUserId(openId);
			zjfPayment.setPaymentStatus("fail");
			zjfPayment.setPaymentResult(0);
			zjfPayment.setPaymentMessage("未找到用户信息");
			zjfPaymentDAO.save(zjfPayment);
			resultMap.put("errmessage", "未找到用户信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfUserList.size()>1){
			zjfPayment.setUserId(openId);
			zjfPayment.setPaymentStatus("fail");
			zjfPayment.setPaymentResult(0);
			zjfPayment.setPaymentMessage("符合的用户信息有多条，无法匹配");
			zjfPaymentDAO.save(zjfPayment);
			resultMap.put("errmessage", "符合的用户信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		
		ZjfUser zjfUser=zjfUserList.get(0);
		
		
		pojos =new Class[] {ZjfOrder.class};
		propertyNames=new String[]{"zjfOrder.orderId","zjfOrder.userId","zjfOrder.disabledState"};
		values=new String[]{orderId,zjfUser.getUserId(),"0"};
		List<ZjfOrder> zjfOrderList  = zjfOrderDAO.findByProperties(pojos, propertyNames, values, likePropertyNames, likevalues, betweenPropertyNames, betweenvalues, orderByPropertyNames, orderByValues, currentPage);
		if(zjfOrderList==null||zjfOrderList.size()<=0){
			zjfPayment.setUserId(zjfUser.getUserId());
			zjfPayment.setPaymentStatus("fail");
			zjfPayment.setPaymentResult(0);
			zjfPayment.setPaymentMessage("未找到订单信息");
			zjfPaymentDAO.save(zjfPayment);
			resultMap.put("errmessage", "未找到订单信息");
			return JSON.toJSONString(resultMap);
		}
		if(zjfOrderList.size()>1){
			zjfPayment.setUserId(zjfUser.getUserId());
			zjfPayment.setPaymentStatus("fail");
			zjfPayment.setPaymentResult(0);
			zjfPayment.setPaymentMessage("符合的订单信息有多条，无法匹配");
			zjfPaymentDAO.save(zjfPayment);
			resultMap.put("errmessage", "符合的订单信息有多条，无法匹配");
			return JSON.toJSONString(resultMap);
		}
		
		zjfPayment.setUserId(zjfUser.getUserId());
		zjfPayment.setPaymentStatus("succ");
		zjfPayment.setPaymentResult(1);
		zjfPayment.setPaymentMessage("");
		zjfPaymentDAO.save(zjfPayment);
		
		ZjfOrder zjfOrder=zjfOrderList.get(0);
		/*
		 * 完成订单支付 修改订单状态  保存支付记录
		 */
		zjfOrder.setOrderStatus(5);
		zjfOrder.setOrderPayStatus(1);
		zjfOrder.setOrderPayment(paymoneyBigDecimal);
		zjfOrder.setOrderNum(payment_trade_no);
		zjfOrder.setOrderLastChangeTime(DateTime.getDateTime());
		zjfOrder.setUpdateTime(DateTime.getDateTime());
		zjfOrder.setUpdateUser(openId);
		zjfOrderDAO.update(zjfOrder);
		
		resultMap.put("result", Contants.CALL_RESULT_SUCC);
		resultMap.put("errmessage", "");
		return JSON.toJSONString(resultMap);
	}
	public void setZjfGoodsClassDAO(ZjfGoodsClassDAO zjfGoodsClassDAO) {
		this.zjfGoodsClassDAO = zjfGoodsClassDAO;
	}
	public void setZjfGoodsTypeDAO(ZjfGoodsTypeDAO zjfGoodsTypeDAO) {
		this.zjfGoodsTypeDAO = zjfGoodsTypeDAO;
	}
	public void setZjfGoodsDAO(ZjfGoodsDAO zjfGoodsDAO) {
		this.zjfGoodsDAO = zjfGoodsDAO;
	}
	public void setZjfGoodsAdDAO(ZjfGoodsAdDAO zjfGoodsAdDAO) {
		this.zjfGoodsAdDAO = zjfGoodsAdDAO;
	}
	public void setZjfGoodsActivityDAO(ZjfGoodsActivityDAO zjfGoodsActivityDAO) {
		this.zjfGoodsActivityDAO = zjfGoodsActivityDAO;
	}
	public void setZjfCliffordDAO(ZjfCliffordDAO zjfCliffordDAO) {
		this.zjfCliffordDAO = zjfCliffordDAO;
	}
	public void setZjfCliffordRecordDAO(ZjfCliffordRecordDAO zjfCliffordRecordDAO) {
		this.zjfCliffordRecordDAO = zjfCliffordRecordDAO;
	}
	public void setZjfGoodsActivityRecordDAO(
			ZjfGoodsActivityRecordDAO zjfGoodsActivityRecordDAO) {
		this.zjfGoodsActivityRecordDAO = zjfGoodsActivityRecordDAO;
	}
	public void setZjfUserAddressDAO(ZjfUserAddressDAO zjfUserAddressDAO) {
		this.zjfUserAddressDAO = zjfUserAddressDAO;
	}
	public void setZjfUserDAO(ZjfUserDAO zjfUserDAO) {
		this.zjfUserDAO = zjfUserDAO;
	}
	public void setZjfLabelDAO(ZjfLabelDAO zjfLabelDAO) {
		this.zjfLabelDAO = zjfLabelDAO;
	}
	public void setZjfBlessDAO(ZjfBlessDAO zjfBlessDAO) {
		this.zjfBlessDAO = zjfBlessDAO;
	}
	public void setZjfCarItemDAO(ZjfCarItemDAO zjfCarItemDAO) {
		this.zjfCarItemDAO = zjfCarItemDAO;
	}
	public void setZjfOrderDAO(ZjfOrderDAO zjfOrderDAO) {
		this.zjfOrderDAO = zjfOrderDAO;
	}
	public void setZjfOrderItemDAO(ZjfOrderItemDAO zjfOrderItemDAO) {
		this.zjfOrderItemDAO = zjfOrderItemDAO;
	}
	public void setZjfPaymentDAO(ZjfPaymentDAO zjfPaymentDAO) {
		this.zjfPaymentDAO = zjfPaymentDAO;
	}

}
